import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { versionDistributionReducerInitState } from "@/constant";
import { produce } from "immer";
import type {VersionDistributionType,VersionReducerInitStateType} from "@/types/reducer"
const versionDistSlice = createSlice({
  name: "version_distribution",
  initialState: {
    versonDist: versionDistributionReducerInitState,
  },
  //相当于reducer
  reducers: {
    //设置运维支撑数据
    setVerisionDistData: produce(
      (
        state: VersionReducerInitStateType,
        action: PayloadAction<VersionDistributionType>
      ) => {
        state.versonDist = action.payload;
      }
    ),
  
  },
});

//导出action，在组件中用
export const { setVerisionDistData } = versionDistSlice.actions;
export default versionDistSlice.reducer;
